package entity;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import common.BaseModelObject;

@Entity
public class Equipment extends BaseModelObject {

	public static enum STATE {
		EQUIPMENTNEW, EQUIPMENTINSTORE, EQUIPMENTBORROWED, EQUIPMENTBAD
	}

	private String name;

	private STATE state;

	@ManyToOne
	private Account account;
	@OneToMany(mappedBy = "equipment", cascade = CascadeType.ALL)
	private Collection<Event> events = new ArrayList<Event>();

	public Equipment(String name, Account account) {
		this.name = name;
		this.account = account;
		this.state = STATE.EQUIPMENTNEW;
		if (account != null)
			account.getEquipments().add(this);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public Collection<Event> getEvents() {
		return events;
	}

	public void setEvents(Collection<Event> events) {
		this.events = events;
	}

	public STATE getState() {
		return state;
	}

	public void setState(STATE state) {
		this.state = state;
	}

}